home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
assemblr
/
library
/
delays
/
delays.asm
next >
Wrap
Assembly Source File
|
1992-12-13
|
5KB
|
113 lines
;; DELAYS.ASM - three methods to create delays.
;;
;; MILLI_DELAY: ---------- PORT addressing method.
;;
;; BIO_ADDR_DELAY: ------- BIO's addressing method.
;;
;; BIO_INT_DELAY: -------- BIO's interrupt method.
;;
;;
;; This code is "PUBLIC DOMAIN"
;;
;; by William Cravener 12/13/92
;;
;;--------------------------------------------------------------------------
;;
code SEGMENT
ASSUME cs:code, ds:code, es:code, ss:code
ORG 100h ; COM files begin here
start:
call milli_delay ; call first delay method
mov al, 31h ; ascii number 1
call writeit ; go show it
call bio_addr_delay ; call second delay method
mov al, 32h ; ascii number 2
call writeit ; go show it
call bio_int_delay ; call third delay method
mov al, 33h ; ascii number 3
call writeit ; go show it
mov ah, 1 ; BIO's keyboard service
int 16h ; see if key was pressed
jz start ; jump to start if not
mov ah, 0 ; BIO's keyboard service
int 16h ; eat just pressed key
int 20h ; key was pressed - exit
;----------------------------------
writeit:
mov ah, 0eh ; BIO's teletype service
mov bh, 0 ; page 0
int 10h ; interrupt
mov al, 0dh ; do a return
int 10h ; interrupt
ret
;---------------------------;
; PORT ADDRESSING METHOD. ;
; ;
; The value placed in BX ;
; determines delay period. ;
;---------------------------;
milli_delay:
mov BX, 2850 ; roughly 1 second delay
milli:
mov al, 6 ; binary mode 3 channel 0
out 43h, al ; to counter command port
in al, 40h ; retrieve LSB from channel 0
mov dl, al ; place LSB in DL
in al, 40h ; retrieve MSB from channel 0
mov dh, al ; place MSB in DH
sub dx, 1193 ; roughly 1 millisec ( 1193180/1000 )
one_ms:
mov al, 6 ; binary mode 3 channel 0
out 43h, al ; to counter command port
in al, 40h ; retrieve LSB from channel 0
mov cl, al ; place LSB in CL
in al, 40h ; retrieve MSB from channel 0
mov ch, al ; place MSB in CH
cmp cx, dx ; CX greater then DX
ja one_ms ; yes - retrieve new count
dec bx ; milliseconds counter
jnz milli ; continue if not finished
ret
;;
;---------------------------;
; BIO's ADDRESS METHOD. ;
; ;
; The value placed in CX ;
; determines delay period. ;
;---------------------------;
bio_addr_delay:
push es ; save ES
mov ax, 40h ; BIO's
mov es, ax ; segment
mov bx, 6ch ; tick counter address
mov ax, es:[bx] ; place tick count in AX
mov CX, 18 ; roughly 1 second delay
delay_it:
cmp ax, es:[bx] ; are they equal
je delay_it ; yes continue
mov ax, es:[bx] ; no get new count
loop delay_it ; loop for 18 ticks
pop es ; restore ES
ret
;;
;---------------------------;
; BIO's INTERRUPT METHOD. ;
; ;
; The value added to DX ;
; determines delay period. ;
;---------------------------;
bio_int_delay:
mov ah, 0 ; clock count service
int 1ah ; BIO's date time interrupt
add DX, 18 ; roughly 1 second delay
mov bx, dx ; move it to BX for compare
delayit:
int 1ah ; get another tick count
cmp dx, bx ; new tick in DX = BX yet?
jne delayit ; NO - get next tick count
; YES - DX = BX
ret
;;---------------------------------------------------------------------------
code ENDS
END start